#include<iostream>
#include<cstring>
using namespace std;

int find_max_min(int n, int array[]) {
	int max, min, tmp = 0;
	for (int i = 0; i < n; i++) {
		if (tmp < array[i]) {
			tmp = array[i];
		}
		max = tmp;
	}
	for (int i = 0; i < n; i++) {
		if (tmp > array[i]) {
			tmp = array[i];
		}
		min = tmp;
	}

	cout << max << endl << min;
}

int main() {

	int n;
	int array[100] = {1, 2, 3};


	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> array[i];
	}
	find_max_min(n, array);


	return 0;
}
